package csm.web.core.search;

import java.util.ArrayList;
import java.util.List;

import csm.common.ListHelper;

public abstract class SearchResultInfo {

	private String webPageUrl;
	private String query; // 사용자로부터 전달된 검색어
	private String engineQuery; // 엔진에 최종적으로 전달할 수 있도록 가공된 질의어.
	private String resultString;

	private int hitCount;
	private int page;
	private int pageSize;
	private List<BriefItem> items;

	private ListHelper<BriefItem> pageHelper;

	private boolean isRaisedError = false;
	private String errorMessage = "";


	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public boolean isRaisedError() {
		return isRaisedError;
	}

	public void setRaisedError(boolean isRaisedError) {
		this.isRaisedError = isRaisedError;
	}

	public SearchResultInfo()
	{
		this.items = new ArrayList<BriefItem>();
	}

	public abstract void parseResult( String responseString );

	public ListHelper<BriefItem> getPageHelper() {

		if( pageHelper == null){
			pageHelper = new ListHelper<BriefItem>(items, hitCount, page, pageSize, 10);
		}
		return pageHelper;
	}

	public void setPageHelper(ListHelper<BriefItem> pageHelper) {
		this.pageHelper = pageHelper;
	}

	protected void addBriefItem( BriefItem item)
	{
		this.items.add(item);
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}



	public String getEngineQuery() {
		return engineQuery;
	}

	public void setEngineQuery(String engineQuery) {
		this.engineQuery = engineQuery;
	}



	public String getResultString() {
		return resultString;
	}

	public void setResultString(String resultString) {
		this.resultString = resultString;
	}



	public int getHitCount() {
		return hitCount;
	}

	public void setHitCount(int hitCount) {
		this.hitCount = hitCount;
	}



	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}



	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}



	public List<BriefItem> getItems() {
		return items;
	}

	public void setItems(List<BriefItem> items) {
		this.items = items;
	}

	public String getWebPageUrl() {
		return webPageUrl;
	}

	public void setWebPageUrl(String webPageUrl) {
		this.webPageUrl = webPageUrl;
	}
}
